#include"../http.hpp"

//int main()
//{
//    Socket sock;
//    // 想要连接哪台主机？主机的哪个端口？
//    sock.CreateOneClient("39.99.241.107",8888);
//
//    //TODO
//    int cnt=1;
//    while(cnt<=3){
//        sock.Send("hello,i am client!",30);
//        char buffer[1024];
//        sock.Recv(buffer,sizeof(buffer));
//        std::cout<<buffer<<std::endl;
//        cnt++;
//    }
//    sleep(6);
//    sock.Close();
//    return 0;
//}
int main()
{
 	Socket cli_sock; 
	cli_sock.CreateOneClient("127.0.0.1",8888); 
	std::string head = "PUT /1234.txt HTTP/1.1\r\nConnection: keep-alive\r\n";
	std::string body;
	Util::ReadFromFile("./hello.txt",body);
	head+="Content-Length: "+std::to_string(body.size())+"\r\n\r\n";
 	
 	assert(cli_sock.Send(head.c_str(), head.size()) != -1); 
 	assert(cli_sock.Send(body.c_str(), body.size()) != -1); 
	char buf[1024] = {0}; 
	assert(cli_sock.Recv(buf, 1023)>0);
 	Log(Info,"[%s]",buf); 
	sleep(3);
 	
 	cli_sock.Close(); return 0;
}
